package com.efesco.inchar.maintenance;

import java.util.Date;

import com.bstek.dorado.data.*;
import com.bstek.dorado.common.*;
import com.bstek.dorado.utils.variant.VariantSet;
import com.bstek.dorado.data.db.DBStatement;

/**
 * InCharMaintenance_datasetTypeServiceListener
 */
public class InCharMaintenance_datasetMaterialListener extends AbstractDatasetListener {
  public boolean beforeUpdateData(Dataset dataset)
     throws Exception {
    VariantSet varSet;
    DBStatement st = new DBStatement();
    try {
      st.setSql("SELECT GENERAL.Nextval FROM DUAL");
        
      dataset.moveFirst();
      while (!dataset.isLast()) {
        if (dataset.getRecordState() == Record.STATE_NEW) {
          varSet = st.query();
          long newId = varSet.getLong(0);
          dataset.setLong("MATERIAL_ID", newId);
        }

        dataset.moveNext();
      }
      
    }
    finally {
      st.close();
    }

    return true;

  }

}

